<?php
//require_once('../user/wxbrower.php');
require_once("../includes/public.inc.php");
$s = isset($_GET['s'])?$_GET['s']:'';
//使用防伪码进行查询，如果数据库有这个码，然后放到随机库里面查询，如果有就中奖没有就写很遗憾没有中奖randomcode
$fwm = mysql_fetch_array(mysql_query("select id,fwm,time from ".DBQIAN."fwm where fwm='".trim($s)."' and status=0 order by id desc limit 1"));//未使用,未领取奖品的
$fwm1 = mysql_fetch_array(mysql_query("select id,fwm,time from ".DBQIAN."fwm where fwm='".trim($s)."' and status=1 order by id desc limit 1"));//已使用
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no,width=device-width, initial-scale=1.0 maximum-scale=1.0">
<meta name="Keywords" content="正品验证" />
<meta name="Description" content="正品验证" />
<title>FBK-益美佳（广州）制动器有限公司</title>
<script src="./Public/js/jquery-1.7.2.min.js"></script>
<script language="javascript" type="text/javascript" src="Public/js/sel.js"   charset="gb2312"></script>
<script type="text/javascript">
	var ua = navigator.userAgent;
	var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
    isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
    isAndroid = ua.match(/(Android)\s+([\d.]+)/),
    isMobile = isIphone || isAndroid;
    if(isMobile) 
    {
        return true;
    }
    else
    {
        location.href = 'tip.php';
    }
    //或者单独判断iphone或android 
//    if(isIphone){
//        //code 
//    else if(isAndroid){
//        //code
//    }else{
//        //code
//    }
</script>
<style type="text/css">
.td{border:solid #000; border-width:0px 1px 1px 0px; padding:10px 0px;}
.table{border:solid #000; border-width:1px 0px 0px 1px;}
input
{
	BACKGROUND-COLOR: transparent;
	BORDER-BOTTOM: #000 1px solid;
	BORDER-LEFT: #000 1px solid;
	BORDER-RIGHT: #000 1px solid;
	BORDER-TOP: #000 1px solid;
	COLOR: #FFF;
	WIDTH:200px;
	HEIGHT: 28px;
	border-color: #FFD300 #FFD300 #FFD300 #FFD300; font-size: 9pt;
	-moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius:5px;
}
</style>
</head>
<body style="margin-top:0px;margin-left:auto;margin-right:auto;height:100%;">
<div id="formbackground" style="position:absolute; width:100%; height:100%; z-index:-199;float:left;">
	<img src="../images/23.jpg" height="100%" width="100%" style="margin-left:0px;"/>
</div>
<?
	if ($fwm)
	{
?>
<div style="width:90%; ">
	<div style="width:100%;position:absolute;text-align:center;margin-top:30px;">
		<table style="margin-left:auto;margin-right:auto;background-color:#000;opacity: 0.7;-moz-border-radius: 10px;-webkit-border-radius: 10px;border-radius:10px;">
			<tr >
				<td style="color:#fff;">查询结果:</td><td width="228px"  style="color:#FD7297;font-size:0.76em;font-weight:bolder;"  align="left">你好!你所查询的产品为正品,请放心使用！</td>
			</tr>
			<tr >
				<td width="72px" style="color:#fff;">防&nbsp;&nbsp;伪&nbsp;&nbsp;码:</td><td width="228px" align="left"><span style="color:#FD3F72;font-size:15px; font-weight:bolder;"><?=$fwm['fwm']?></span></td>
			</tr>
			<tr >
				
			</tr>
			<tr>
				<td style="color:#fff;">生产公司:</td><td align="left"><span style="width:100%;color:#ff0; font-size:14px; font-weight:bolder;margin-left:auto;margin-right:auto;text-align:center;">益美佳（广州）制动器有限公司</span></td>
			</tr>
		</table>
	</div>
</div>
<div style="width:90%;">
	<div style="width:100%;position:absolute; text-align:center;margin-top:152px;">
		<form name="fbk" id="fbk" action="fbkhuoqu.php" method="post" >
				<table style="margin-left:auto;margin-right:auto;background-color:#000;opacity: 0.7;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius:6px;">
					<tr >
						<td style="color:#FC0044; font-size:20px; font-weight:bolder;" colspan="2"  height="40px">奖品邮寄信息</td>
					</tr>
					<tr >
						<td style="color:#fff;"  height="40px">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</td><td style="color:#f0f;" align="left"><input name="name" id="name" value="" type="text"/></td>
					</tr>
					<tr >
						<td width="72px" height="40px" style="color:#fff;">联系电话:</td><td width="228px" align="left"><span style="color:#f00;font-size:15px;"><input name="tel" id="tel" value="" placeholder="手机/固定电话(区号-电话号码)" type="text" style=""/></span></td>
					</tr>
					<tr >
						<td width="72px"  height="40px" style="color:#fff;">省&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;份:</td><td width="228px" align="left">
						<span style="color:#f00;font-size:15px;">
							<select id="selProvince" name="province" style="WIDTH:200px;HEIGHT:28px;moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius:5px;" onchange="provinceChange();"></select>
						</span>
						</td>
					</tr>
					<tr >
						<td width="72px"  height="40px" style="color:#fff;">市&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;县:</td><td width="228px" align="left">
							<span style="color:#f00;font-size:15px;">
								<select id="selCity" name="city" style="WIDTH:200px;HEIGHT:28px;moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius:5px;"></select> 
							</span>
						</td>
					</tr>
					<tr >
						<td width="72px"  height="40px" style="color:#fff;">详细地址:</td><td width="228px" align="left"><span style="color:#f00;font-size:15px;"><input name="address" id="address" value="" type="text" style=""/></span></td>
					</tr>
					<tr >
						<td width="72px"  height="40px" style="color:#fff;">车&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型:</td><td width="228px" align="left"><span style="color:#f00;font-size:15px;"><input name="car_type" id="car_type" value="" type="text" style=""/></span></td>
					</tr>
					<tr>
						<td style="color:#FD7297; font-weight:bolder;" colspan="2"  height="40px">
							<input type="hidden" name="fwm" value="<?=$fwm['fwm']?>" />
							<input type="submit" style="font-size:14px;font-weight:bolder; background-color:#FC0044;border-color:#BD2F55; width:100%;height:32px;" value="提交抽奖" >
						</td>
					</tr>
					<tr>
						<td style="color:#FFD300; font-size:10px;" colspan="2"  height="40px">该活动的最终解释权归益美佳(广州)制动器有限公司所有</td>
					</tr>
				</table>
		</form>
	</div>
</div>
<?
	}
	else //已经查询或者是假冒的
	{
		if ($fwm1)//已查询
		{
?>
			<div style="width:90%; ">
				<div style="width:100%;position:absolute;text-align:center;margin-top:56%;">
					<table style="margin-left:auto;margin-right:auto;background-color:#000;opacity: 0.7;-moz-border-radius: 10px;-webkit-border-radius: 10px;border-radius:10px;">
						<tr >
							<td style="color:#fff;">查询结果:</td><td width="250px"  style="color:#FD7297;font-size:0.7em;font-weight:bolder;"  align="left">你好!该防伪码在<?=$fwm1['time']?>已被查询！</td>
						</tr>
						<tr >
							<td width="72px" style="color:#fff;">防&nbsp;&nbsp;伪&nbsp;&nbsp;码:</td><td width="250px" align="left"><span style="color:#FD3F72;font-size:15px; font-weight:bolder;"><?=$fwm1['fwm']?></span></td>
						</tr>
						<tr >
							
						</tr>
						<tr>
							<td style="color:#fff;">生产公司:</td><td align="left"><span style="width:100%;color:#ff0; font-size:14px; font-weight:bolder;margin-left:auto;margin-right:auto;text-align:center;">益美佳（广州）制动器有限公司</span></td>
						</tr>
					</table>
				</div>
			</div>
<?
		}
		else //假冒
		{
?>
			<div style="width:90%;">
				<div style="width:100%;position:absolute;text-align:center;margin-top:55%;">
					<table style="margin-left:auto;margin-right:auto;background-color:#000;padding:15px;opacity: 0.7;-moz-border-radius: 10px;-webkit-border-radius: 10px;border-radius:10px;">
						<tr >
							<td width="280px" style="color:#FF0;font-size:1em;font-weight:bolder;"  align="left">你好!你所查询的产品为<span style="color:#f00;">假冒</span>产品。<br/><br/>请谨慎使用！</td>
						</tr>
					</table>
				</div>
			</div>
<?
		}
	}
?>
<script type="text/javascript">
$(function()
{
    $('#formbackground').height($(window).height());
    $('#formbackground').width($(window).width());
    $('#fbk').submit(function(){
    	 var name=$('#name').val();
        var tel=$('#tel').val();
        var address=$('#address').val();
        var car_type=$('#car_type').val();
		if (!name)
		{
			alert('请输入你的姓名');return false;
		}
		if (!tel)
		{
			alert('请输入你的电话或者手机号码');return false;
		}
		else
		{
			if (!istell(tel) && !vailPhone(tel))
			{ 
				alert('请输入正确的电话或者手机号码');return false;
			}
		}
		if (!address)
		{
			alert('请输入你的详细地址，仅用来发放礼品的 ');return false;
		}
		if (!car_type)
		{
			alert('请输入你的车型，否则不能参此次抽奖活动 ');return false;
		}
    });
});
function istell(str)
{
	var result=str.match(/\d{3}-\d{8}|\d{4}-\d{7}/);
	if(result==null) return false;
	return true;
}
function vailPhone(str){
    var phone = str;//jQuery("#phone").val();
    var flag = false;
    var message = "";
    var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;       
    if(phone == ''){
      message = "手机号码不能为空！";
    }else if(phone.length !=11){
      message = "请输入有效的手机号码！";
    }else if(!myreg.test(phone)){
      message = "请输入有效的手机号码！";
    }else if(checkPhoneIsExist()){
      message = "该手机号码已经被绑定！";
    }else{
        flag = true;
    }
    if(!flag){
   //提示错误效果
      //jQuery("#phoneDiv").removeClass().addClass("ui-form-item has-error");
      //jQuery("#phoneP").html("");
      //jQuery("#phoneP").html("<i class=\"icon-error ui-margin-right10\"> <\/i>"+message);
      //jQuery("#phone").focus();
    }else{
         //提示正确效果
      //jQuery("#phoneDiv").removeClass().addClass("ui-form-item has-success");
      //jQuery("#phoneP").html("");
      //jQuery("#phoneP").html("<i class=\"icon-success ui-margin-right10\"> <\/i>该手机号码可用");
    }
    return flag;
  }

</script>
</body>
</html>